package com.idanchuang.component.consumer;

import com.idanchuang.component.core.helper.EnvContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 *
 * feign请求压测环境拦截器
 * @author yjy
 */
public class FeignPressureInterceptor implements RequestInterceptor {

    public FeignPressureInterceptor() {
    }

    @Override
    public void apply(RequestTemplate requestTemplate) {
        String headerName = EnvContext.getEnvHeaderName();
        String currentEnv = EnvContext.getCurrentEnv();
        if (currentEnv != null) {
            requestTemplate.header(headerName, EnvContext.getCurrentEnv());
        } else {
            requestTemplate.header(headerName);
        }
    }
}